package com.nave.princesslife.baseboard.functionality;

import java.util.List;

import com.nave.princesslife.R;
import com.nave.princesslife.main.ItemsBought;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Room_AcessoriesAdapter extends BaseAdapter {

	private Context context;
	private List<Acessories_Base> acessories;

	public Room_AcessoriesAdapter(Context context, List<Acessories_Base> acessories) {
		this.context = context;
		this.acessories = acessories;
	}

	@Override
	public int getCount() {
		return acessories.size();
	}

	@Override
	public Object getItem(int position) {
		return acessories.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		Acessories_Base ab = acessories.get(position);
		LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.activity_room_acessories, null);

		TextView acessoryName = (TextView) v.findViewById(R.id.room_acessories_name);
		ImageView iv = (ImageView) v.findViewById(R.id.room_acessories_image);

		acessoryName.setText(ab.getAcessoryName());
		iv.setImageResource(ab.getAcessoryImage());

		// Se for a roupa atual, deixar o background verde.
		for (Bitmap bit : ItemsBought.getInstance().getCurrentAcessory()) {
			if (ab.getBitmap() == bit)
				v.setBackgroundColor(Color.rgb(72, 255, 0));
		}

		return v;
	}

}
